package cn.cloud.all.security.access.event;

import cn.cloud.all.security.access.AccessDeniedException;
import cn.cloud.all.security.access.ConfigAttribute;
import cn.cloud.all.security.core.Authentication;

import java.util.Collection;

public class AuthorizationFailureEvent extends AbstractAuthorizationEvent {

    private Authentication authentication;
    private AccessDeniedException accessDeniedException;
    private Collection<ConfigAttribute> configAttributes;

    public AuthorizationFailureEvent(Object secureObject,
                                     Collection<ConfigAttribute> attributes,
                                     Authentication authentication,
                                     AccessDeniedException accessDeniedException) {
        super(secureObject);

        if ((attributes == null) || (authentication == null) || (accessDeniedException == null)) {
            throw new IllegalArgumentException("All parameters are required and cannot be null");
        }

        this.configAttributes = attributes;
        this.authentication = authentication;
        this.accessDeniedException = accessDeniedException;
    }

    public AccessDeniedException getAccessDeniedException() {
        return accessDeniedException;
    }

    public Authentication getAuthentication() {
        return authentication;
    }

    public Collection<ConfigAttribute> getConfigAttributes() {
        return configAttributes;
    }
}
